<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
<c:set var="emp" value="${sessionScope.user }"/>
<div class="mailbox row">
	<div class="col-xs-12">
		<div class="box box-solid">
			<div class="box-body">
				<div class="row">
					<div class="col-md-3 col-sm-4">
						<!-- BOXES are complex enough to move the .box-header around.
                                                 This is an example of having the box header within the box body -->
						<div class="box-header">
							<i class="fa fa-inbox"></i>
							<h3 class="box-title">公告</h3>
						</div>
						<c:forEach var="ro" items="${emp.roles}">
							<c:forEach var="fu" items="${ro.functionAll}">
								<c:if test="${fu.parentId==param.parentId}">
									<c:if test="${fu.code=='announcement-add' }">
										<!-- 申请公告 -->
										<a id="showModal" class="btn btn-block btn-primary" data-toggle="modal"
											data-target="#compose-modal">
											<i class="${fu.menuLog}"></i>
											${fu.name}
										</a>
									</c:if>
								</c:if>
							</c:forEach>
						</c:forEach>
						<!-- 分类导航-->
						<div style="margin-top: 15px;">
							<ul class="nav nav-pills nav-stacked">
								<li class="header">分类</li>
								<c:forEach var="ro" items="${emp.roles}">
									<c:forEach var="fu" items="${ro.functionAll}">
										<c:if test="${fu.parentId==param.parentId}">
											<c:if test="${empty param.status}">
												<c:if test="${fu.code=='announcement-draft' }">
													<li><a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=0"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='announcement-waitpass' }">
													<li><a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=1"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='announcement-passed' }">
													<li class="active"><a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=2"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='annoucement-notpassed' }">
													<li><a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=3"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='annoucement-logout' }">
													<li><a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=4"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
											</c:if>
											<c:if test="${not empty param.status}">
												<c:if test="${fu.code=='announcement-draft' }">
													<c:if test="${param.status==0}">
														<li class="active">
													</c:if>
													<c:if test="${param.status!=0}">
														<li>
													</c:if>
													<a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=0"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='announcement-waitpass' }">
													<c:if test="${param.status==1}">
														<li class="active">
													</c:if>
													<c:if test="${param.status!=1}">
														<li>
													</c:if>
													<a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=1"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='announcement-passed' }">
													<c:if test="${param.status==2}">
														<li class="active">
													</c:if>
													<c:if test="${param.status!=2}">
														<li>
													</c:if>
													<a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=2"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='annoucement-notpassed' }">
													<c:if test="${param.status==3}">
														<li class="active">
													</c:if>
													<c:if test="${param.status!=3}">
														<li>
													</c:if>
													<a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=3"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
												<c:if test="${fu.code=='annoucement-logout' }">
													<c:if test="${param.status==4}">
														<li class="active">
													</c:if>
													<c:if test="${param.status!=4}">
														<li>
													</c:if>
													<a href="${initParam.root}/${fu.menuEntry}?parentId=${param.parentId}&status=4"><i class="${fu.menuLog}"></i>${fu.name }</a></li>
												</c:if>
											</c:if>
										</c:if>
									</c:forEach>
								</c:forEach>
							</ul>
						</div>
					</div>
					<!-- /.col (LEFT) -->
					<div class="col-md-9 col-sm-8">
						<div class="row pad">
							<!-- 搜索框 -->
							<div class="col-sm-6 search-form">
								<form action="${initParam.root}/announcement/mine" class="text-right" method="get">
									<div class="input-group">
										<input type="hidden" name="status" value="${param.status}"/>
										<input type="hidden" name="parentId" value="${param.parentId}"/>
										<input name="keyword" type="text" class="form-control input-sm"
											placeholder="输入公告标题关键字" value="${keyword }">
										<div class="input-group-btn">
											<button type="submit" class="btn btn-sm btn-primary">
												<i class="fa fa-search"></i>
											</button>
										</div>
									</div>
								</form>
							</div>
							<div class="col-sm-6"></div>
						</div>
						<!-- /.row -->
						<!-- 	1.table-responsive放在table的上一级
								2.td里的内容增多
								  才会出现滚动条！ -->
						<div class="table-responsive">
							<!-- THE MESSAGES -->
							<table class="table table-mailbox info">
								<tr>
									<th>申请人</th><th>标题</th><th>最后修改</th><th>审批人</th><th>审批时间</th>
								</tr>
								<c:forEach var="a" items="${announcement}" >
									<c:if test="${status==0}">
										<tr class="editAnnouncement" data-toggle="modal"
							data-target="#compose-modal" ref-id="${a.id}" ref-content="${a.content}"
							 ref-title="${a.title}">
											<td class="name">${a.creator.name}</td>
											<td class="subject">${a.title}</td>
											<td class="time"><fmt:formatDate value="${a.lastEditTime}" pattern="yyyy-MM-dd HH:mm"/></td>
											<td class="subject">${a.approver.name}</td>
											<td class="time"><fmt:formatDate value="${a.approveTime}" pattern="yyyy-MM-dd HH:mm"/></td>
										</tr>
									</c:if>
									<c:if test="${status==1}">
										<tr class="announcementInfo" ref-id="${a.id}" ref-status="${status}">
											<td class="name">${a.creator.name}</td>
											<td class="subject">${a.title}</td>
											<td class="time"><fmt:formatDate value="${a.lastEditTime}" pattern="yyyy-MM-dd HH:mm"/></td>
											<td class="subject">${a.approver.name}</td>
											<td class="time"><fmt:formatDate value="${a.approveTime}" pattern="yyyy-MM-dd HH:mm"/></td>
										</tr>
									</c:if>
									<c:if test="${status==2}">
										<tr class="announcementInfo"  ref-id="${a.id}" ref-status="${status}">
											<td class="name">${a.creator.name}</td>
											<td class="subject">${a.title}</td>
											<td class="time"><fmt:formatDate value="${a.lastEditTime}" pattern="yyyy-MM-dd HH:mm"/></td>
											<td class="subject">${a.approver.name}</td>
											<td class="time"><fmt:formatDate value="${a.approveTime}" pattern="yyyy-MM-dd HH:mm"/></td>
										</tr>
									</c:if>
									<c:if test="${status==3}">
										<tr class="announcementInfo"  ref-id="${a.id}" ref-status="${status}">
											<td class="name">${a.creator.name}</td>
											<td class="subject">${a.title}</td>
											<td class="time"><fmt:formatDate value="${a.lastEditTime}" pattern="yyyy-MM-dd HH:mm"/></td>
											<td class="subject">${a.approver.name}</td>
											<td class="time"><fmt:formatDate value="${a.approveTime}" pattern="yyyy-MM-dd HH:mm"/></td>
										</tr>
									</c:if>
									<c:if test="${status==4}">
										<tr class="announcementInfo"  ref-id="${a.id}" ref-status="${status}">
											<td class="name">${a.creator.name}</td>
											<td class="subject">${a.title}</td>
											<td class="time"><fmt:formatDate value="${a.lastEditTime}" pattern="yyyy-MM-dd HH:mm"/></td>
											<td class="subject">${a.approver.name}</td>
											<td class="time"><fmt:formatDate value="${a.approveTime}" pattern="yyyy-MM-dd HH:mm"/></td>
										</tr>
									</c:if>
								</c:forEach>
							</table>
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /.col (RIGHT) -->
				</div>
				<!-- /.row -->
			</div>
			<!-- /.box-body -->
			<div class="box-footer clearfix">
				<div class="pull-right">
					<small>显示<span>第${pageNum}页</span>共${totalPage}页</small>
					<c:if test="${pageNum>1}">
						<a href="${initParam.root}/announcement/mine?keyword=${keyword}&status=${status}&pageNum=${pageNum-1}">
							<button class="btn btn-xs btn-primary">
								<i class="fa fa-caret-left"></i>
							</button>
						</a>
					</c:if>
					<c:if test="${pageNum==1}">
						<button class="btn btn-xs btn-primary">
							<i class="fa fa-caret-left"></i>
						</button>
					</c:if>
					<c:if test="${pageNum<totalPage}">
						<a href="${initParam.root}/announcement/mine?keyword=${keyword}&status=${status}&pageNum=${pageNum+1}">
							<button class="btn btn-xs btn-primary">
								<i class="fa fa-caret-right"></i>
							</button>
						</a>
					</c:if>
					<c:if test="${pageNum==totalPage}">
						<button class="btn btn-xs btn-primary">
							<i class="fa fa-caret-right"></i>
						</button>
					</c:if>
				</div>
			</div>
			<!-- box-footer -->
		</div>
		<!-- /.box -->
	</div>
	<!-- /.col (MAIN) -->
</div>
<!-- MAILBOX END -->